//
//  HomeTopView.swift
//  HR
//
//  Created by zhenyu on 17/6/6.
//  Copyright © 2017年 allblue. All rights reserved.
//

import UIKit

class HomeTopView: UIView {
  
  weak var city: UILabel!
  
  // MARK: - LifeCycle
  override init(frame: CGRect) {
    super.init(frame: frame)
    setViews()
  }
  
  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }
  
  
  // MARK: - SetViews
  func setViews() {
    let contentView = UIView().then { (v) in
      addSubview(v)
      v.backgroundColor = Color.theme
      v.snp.makeConstraints({ (make) in
        make.top.left.bottom.right.equalTo(self)
      })
    }
    
    city = UILabel().then({ (l) in
      contentView.addSubview(l)
      l.text = "贵州"
      l.textColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
      l.font = HRFont(size: 14)
      l.snp.makeConstraints({ (make) in
        make.left.equalTo(13)
        make.centerY.equalTo(contentView).offset(15)
      })
    })
    
    let scanView = UIImageView().then { (i) in
      i.image = #imageLiteral(resourceName: "h_scan")
      contentView.addSubview(i)
      i.snp.makeConstraints({ (make) in
        make.centerY.equalTo(city)
        make.right.equalTo(contentView.snp.right).offset(-28)
      })
    }
    
    let searchView  = UIView().then { (v) in
      contentView.addSubview(v)
      v.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
      v.layer.cornerRadius = 15
      v.snp.makeConstraints({ (make) in
        make.centerY.equalTo(city)
        make.left.equalTo(city.snp.right).offset(13)
        make.right.equalTo(scanView.snp.left).offset(-13)
        make.height.equalTo(30)
      })
    }
    
    let searchTilte = UILabel().then({ (l) in
      searchView.addSubview(l)
      l.text = "搜索单位/岗位"
      l.textColor = Color.lightFont
      l.font = HRFont(size: 14)
      l.snp.makeConstraints({ (make) in
        make.center.equalTo(searchView)
      })
    })
    
    _ = UIImageView(image: #imageLiteral(resourceName: "h_search")).then({ (i) in
      searchView.addSubview(i)
      i.snp.makeConstraints({ (make) in
        make.right.equalTo(searchTilte.snp.left).offset(-9)
        make.centerY.equalTo(searchTilte)
      })
    })
  }
}
